package com.welsmann.app.start.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import com.welsmann.app.start.common.StartConst;
import com.welsmann.app.start.common.StartUtil;
import com.welsmann.app.start.service.IHolidayService;
import com.welsmann.app.start.service.ISiteService;

public class BaseController {

	private String _holiday_type_lf = "农历节日";

	private String _holiday_type_l = "二十四节气";

	private String _holiday_type_c = "国内节日";

	private String _holiday_type_i = "国际节日";

	@Resource(name = "HolidayService")
	protected IHolidayService holidayService;
	
	@Resource(name = "SiteService")
	protected ISiteService siteService;
	
	@Autowired  
	private HttpServletRequest request; 
	
	/**
	 * 获取默认的假日信息（今天的节日）
	 * 
	 * @return
	 */
	protected String getCurrentHoliday() {
		int[] date = StartUtil.getMonthAndDay();
		return holidayService.getHolidayByDate(date[0], date[1]);
	}

	/**
	 * 获取假日类型
	 * 
	 * @param type
	 * @return
	 */
	protected String getHolidayType(int type) {
		switch (type) {
		case StartConst.HOLIDAY_TYPE_L_F:
			return _holiday_type_lf;
		case StartConst.HOLIDAY_TYPE_L:
			return _holiday_type_l;
		case StartConst.HOLIDAY_TYPE_C:
			return _holiday_type_c;
		default:
			return _holiday_type_i;
		}
	}
	
	public HttpServletRequest getRequest() {
		return request;
	}
	
	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}
}
